<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 17-2-17
 * Time: 下午8:54
 */


define("MYSQL_CONN_ERROR", "Unable to connect to database.");

// Ensure reporting is setup correctly
mysqli_report(MYSQLI_REPORT_STRICT);

// Connect function for database access
function connect($host,$usr,$pw) {
    try {
        $mysqli = new mysqli($host,$usr,$pw);
    } catch (mysqli_sql_exception $e) {
        throw $e;
    }
}

try {
    connect('localhost','root','root');
    echo 'Connected to database';
} catch (Exception $e) {
    echo $e->getMessage();
//    echo "------------";
}